﻿using System;
class BiggerThanNeigb
{
    static int InputNumber()
    {
        while (true)
        {
            try
            {
                int number = int.Parse(Console.ReadLine());
                return number;
            }
            catch (Exception)
            {
                Console.Write("Please re-enter number: ");
            }
        }
    }
    static bool IsBiggerThanNeighbors(int[] array, int index)
    {
        if ((array[index] > array[index - 1]) && (array[index] > array[index + 1]))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    static void Main()
    {
        int lenght = 0;
        int index = 0;
        bool result;
        Console.Write("please enter the lenght of arrays: ");
        lenght = InputNumber();
        int[] theArray = new int[lenght];
        for (int i = 0; i < lenght; i++)
        {
            Console.Write("Please enter the {0} element of the array: ", i);
            theArray[i] = InputNumber();
        }
        Console.Write("please input index between [1 and {0}]: ", (lenght - 2));
        do
        {
            index = InputNumber();
        } while ((index <= 0) || (index > (lenght - 2)));
        result = IsBiggerThanNeighbors(theArray, index);
        if (result == true)
        {
            Console.WriteLine("the number {0} at index [{1}], is bigger than number {2} at [{3}] and {4} at [{5}]",
                theArray[index], index, theArray[index - 1], index - 1, theArray[index + 1], index + 1);
        }
        else
        {
            Console.WriteLine("the number {0} is smaller than its neighbors");
        }
        Console.ReadLine();
    }
}

